#ifndef THREAD_SERIALPORT_H
#define THREAD_SERIALPORT_H

#include <QThread>
#include <QSerialPort>

class ThreadSerialPort : public QThread
{
    Q_OBJECT

public:
    struct serialParameter
    {
        QString name;
        QSerialPort::BaudRate baud;
        QSerialPort::DataBits datab;
        QSerialPort::StopBits stopb;
        QSerialPort::Parity parity;
    };

    explicit ThreadSerialPort(serialParameter par, QObject* parent = 0);

    int Send(std::shared_ptr<QByteArray> sba);
    int getState();

signals:
    void readData(std::shared_ptr<QByteArray> sba);
    void threadInfo(ThreadSerialPort *info);
    void connected();

protected:
    void run() override;

private slots:
    void slot_readyRead();

private:
    QSerialPort *m_ser;
    QString m_com;
    int m_state;
};

#endif // THREAD_SERIALPORT_H
